var cookieStore={
	setCookie(key,val,expires,path,domain,secure){ 
		let cookieText = encodeURIComponent(key)+ "=" +encodeURIComponent(val);
		if(typeof expires =="number"){
			var d=expires*24*60*60*1000;
			cookieText += ";expires="+new Date(new Date().getTime()+d).toGMTString();
		}
		if(path){
			cookieText += ";path="+path;
		}
		if(domain){
			cookieText += ";domain="+domain;
		}
		if(secure){
			cookieText += ";secure="+secure;
		}
		document.cookie = cookieText;
	},
	getCookie(key){
		let cookieName = encodeURIComponent(key)+"=";
		let cookieStart = document.cookie.indexOf(cookieName);//找到key的索引
		let cookieValue = null;
		if(cookieStart > -1){ //cookie有这个key
			let cookieEnd = document.cookie.indexOf(";" , cookieStart)//查找后边最近的";"的索引
			if(cookieEnd == -1){//这个cookie不是最后的cookie值
				cookieEnd = document.cookie.length;
			}
			cookieValue = decodeURIComponent(document.cookie.substring(cookieStart + cookieName.length , cookieEnd));
		}
		return cookieValue;
	},
	delCookie(key){
		this.set(key,"",new Date(0));
		return key;
	}
}
export default cookieStore;